/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.config.dto.ConfigEndDayQueryDto;
import com.icinfo.cloud.provider.punish.config.dto.ConfigWorkRestDayInfoQueryDto;
import com.icinfo.cloud.provider.punish.config.service.IConfigWorkRestDayInfoService;
import com.icinfo.cloud.provider.punish.config.vo.ConfigWorkRestDayInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

/**
 * 描述: 工作/休息日配置信息表 config_work_rest_day_info 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年03月28日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/config/workRestDay")
@Slf4j
public class ConfigWorkRestDayInfoController extends BaseController {
    @Resource
    private IConfigWorkRestDayInfoService configWorkRestDayInfoService;

    /**
     * 【V1.0.0】描述：获取工作/休息日配置信息列表
     *
     * @param queryDto {@link ConfigWorkRestDayInfoQueryDto}
     * @return {@link List<ConfigWorkRestDayInfoVo>}
     * @author xiangyuyu
     * @date 2022-03-28 19:55
     */
    @PostMapping("/getConfigWorkRestDayInfoList")
    @ApiOperation(value = "【V1.0.0】描述：获取工作/休息日配置信息列表", httpMethod = "POST")
    public Result<List<ConfigWorkRestDayInfoVo>> getConfigWorkRestDayInfoList(@RequestBody @Validated ConfigWorkRestDayInfoQueryDto queryDto) {
        List<ConfigWorkRestDayInfoVo> list = configWorkRestDayInfoService.getConfigWorkRestDayInfoList(queryDto);
        return Result.success(list);
    }

    /**
     * 【V1.0.0】描述：获取指定时间段结束后的截止日期
     *
     * @param queryDto {@link ConfigEndDayQueryDto}
     * @return {@link Result<LocalDate>} 截止日期
     * @author xiangyuyu
     * @date 2022-03-28 21:20
     */
    /*
    测试入参：
    {
        "startDate":"2022-03-28",
        "beforeOrAfterSign":"after",
        "type":"0",
        "dayCount":"6",
        "isContainStartDay":"0"
    }
     */
    @PostMapping("/getPeriodEndDate")
    @ApiOperation(value = "【V1.0.0】描述：获取指定时间段结束后的截止日期", httpMethod = "POST")
    public Result<LocalDate> getPeriodEndDate(@Validated @RequestBody ConfigEndDayQueryDto queryDto) {
        LocalDate deadLine = configWorkRestDayInfoService.getPeriodEndDate(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, deadLine);
    }
}